<template>
	<view class="warp padding-top">
		<!-- 消息内容循环 start -->
		<view class="list margin-lr margin-bottom-sm" @longtap="delMessage(item, index)"
			v-for="(item, index) in listData" :key="index">
			<!-- 平台消息 -->
			<view class="order-item padding-lr padding-top" @click="goDetail(item)">
				<view class="i-top flex align-center justify-between margin-bottom-sm">
					<text class="fu-fs34 text-333">
						<text>{{ item.title }} </text>
					</text>
					<text class="text-bf fu-fs24">{{ item.create_time }}</text>
				</view>
				<view class="goods-box-single flex align-stretch">
					<view class="goods-img overHidden fu-block-150">
						<fu-image :src="item.thumb" mode="aspectFill"></fu-image>
					</view>
					<view class="right order-desc-wrap padding-top-10 margin-left-xs text-999 fu-fs28 padding-xs">
						<scroll-view scroll-y="true" style="height: 130rpx;">
							<view>{{ item.content }}</view>
						</scroll-view>
					</view>
				</view>
				<view class="i-top height-80 line-height-80">
					<text class="come-from"> {{ item.from }}</text>
				</view>
			</view>
		</view>
		<!-- 消息内容循环 end -->
		<!-- 分页组件 start-->
		<fu-empty :paging-list-loaded-all="pagingListLoadedAll" :paging-list-no-list-data="pagingListNoListData"
			:list-data-length="listDataLength" :isLoadInit="isLoadInit"></fu-empty>
		<!-- 分页组件 end-->
		<!-- 网络监测 start -->
		<fu-notwork></fu-notwork>
		<!-- 网络监测  end-->
	</view>
</template>
<script>
	import pagingList from "@/common/mixin/paging_list.js"; //混合开发 请求数据
	export default {
		mixins: [pagingList],
		data() {
			return {
				titleName: global.i18n["消息通知"],
				minixPagingListsApi: global.apiUrls.getOperationGetSystemMsgList, //列表请求地址
				allowOnloadGetList: false, //是否允许请求
				pageingListApiMethod: "get", //请求方式
				msg_type: 3, //消息类型
			};
		},
		/**
		 * @description 页面初始化
		 * @param {Object} e  msg_type:消息类型id,  name:消息类型名称
		 *
		 */
		onLoad(e) {
			this.setSysTitle(e); //设置系统导航名称
			this.msg_type = e.id || 3;
			this.allowOnloadGetList = true;
			this.pagingListGetLists(); //获取数据 调用混用开发里面的方法
			this.setNavigationBarTitle(this.i18n['订单消息']);
		},
		onPullDownRefresh() {
			this.pagingListToggle();
		},
		methods: {
			/**
			 * @description 删除消息
			 * @param {Object} item - id:消息id唯一标识
			 */
			delMessage(item, index) {
				this.$util.showModal({
					title: this.i18n["提示"],
					content: this.i18n["确定删除此消息？"],
					success: (data) => {
						if (data.confirm) {
							this.$api
								.post(global.apiUrls.postOperationDelSystemMsg, {
									id: item.id,
								})
								.then((res) => {
									if (res.data.code == 1) {
										this.listData.splice(index, 1);
										// this.pagingListToggle(); //刷新列表
									} else {
										this.$message.info(res.msg);
									}
								});
						} else if (data.cancel) {
							// console.log('用户点击取消');
						}
					},
				});
			},
			/**
			 * 设置系统导航名称
			 * @param {Object} e name: 消息类型
			 */
			setSysTitle(e) {
				this.titleName = e.name;
				uni.setNavigationBarTitle({
					title: e.name || this.i18n["消息通知"],
				});
			},
			/**
			 * 点击当前通知
			 * @param {Object} item id
			 */
			goDetail(item) {
				this.$urouter.navigateTo({
					url: '/pages/order/orderdetail/order-detail/index',
					params: {
						order_sn: item.order_sn,
						order_type: 3
					}
				})
			},
			/**
			 * 请求分页接口时加入额外参数
			 */
			pagingListPostData() {
				return {
					msgtype: this.msg_type,
					page_size: 10,
				};
			},
		},
	};
</script>

<style lang="scss" scoped>
	.warp {
		height: 100%;
		font-size: 28upx;
		background: #f9f9f9;

		// 消息列表循环 start
		.list {
			.times {
				text-align: center;

				.text {
					display: inline-block;
					margin: 25rpx auto;
					font-size: 22rpx;
					line-height: 30rpx;
					color: #ffffff;
					padding: 1rpx 10rpx;
					border-radius: 5rpx;
					// background: #cccccc;
					text-align: center;
				}
			}

			.consult {
				padding: 25upx;
				width: 100%;
				border-radius: 10rpx;
				background: #fff;
				display: flex;
				flex-direction: column;
				justify-content: space-around;
				color: #999;

				image {
					height: 250rpx;
					border-radius: 20rpx 20rpx 0 0;
					padding-bottom: 20rpx;
				}

				.title {
					font-size: 32rpx;
					color: #000000;
					line-height: 40rpx;
					padding-bottom: 20rpx;
					padding-left: 20rpx;
				}

				.content {
					padding-left: 20rpx;
					font-size: 28upx;
					line-height: 30upx;
					color: rgba(0, 0, 0, 0.4);
					overflow: hidden;
					text-overflow: ellipsis;
					display: -webkit-box;
					-webkit-line-clamp: 2;
					-webkit-box-orient: vertical;
				}
			}
		}

		// 消息列表循环 end
	}

	.order-item {
		display: flex;
		flex-direction: column;
		background: #fff;
		border-radius: 16rpx;
		overflow: hidden;

		.come-from {
			height: 33rpx;
			font-size: 24rpx;
			font-family: PingFang SC;
			font-weight: 400;
			line-height: 33rpx;
			color: #999999;
		}

		/* 单条商品 */
		.goods-box-single {
			.goods-img {
				background-color: #eeeeee;
			}

			.right {
				flex: 1;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				overflow: hidden;

				.attr-box {
					font-size: 24rpx;
					color: #f8f8f8;
					padding: 10upx 12upx;
				}
			}

			.order-desc-wrap {
				background: #fafafa;

				.order-desc {
					word-break: break-all;
					text-overflow: ellipsis;
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 3;
					/* 这里是超出几行省略 */
					overflow: hidden;
				}

			}
		}
	}

	.warp {
		background: inherit;
	}
</style>
